package com.atguigu.mapreduce;

import com.atguigu.mapreduce.shiyan.FamilyRelations;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * @author laberinto
 * @version 1.0
 * @date 2024/10/7 13:35
 * @package com.atguigu.mapreduce
 * @message \\TODO
 * (⌓‿⌓)
 */
public class JobConfig {
    public static Job getJob(String type, Class<?> jarCls,Class<? extends Mapper> mapperCls, Class<? extends Reducer> reducerCls,Class<?> outputKeyClass,Class<?> outputValueClass) throws Exception{
        System.setProperty("HADOOP_USER_NAME","root");
        Configuration conf = new Configuration();
        conf.set("fs.defaultFS","hdfs://master:9000");
        Job job = null;
        try {
            job = Job.getInstance(conf);
        } catch (IOException e) {
            e.printStackTrace();
        }
        job.setJarByClass(jarCls);
        job.setMapperClass(mapperCls);
        job.setReducerClass(reducerCls);
        job.setOutputKeyClass(outputKeyClass);
        job.setOutputValueClass(outputValueClass);
        return job;
    }
}
